function fanList(num=1,size=5){
    return new Promise((reslove,reject)=>{
        axios({
            method: 'get',
            url:'/fan/fansList',
            params: {
                pageNum: num,
                pageSize: size
            },
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            }
        }).then(data=>{
            reslove(data)
        }).catch(err=>{
            reject(err)
        })
    })
}

let i=1
fanList().then(data=>{
    let left_w=document.querySelector('.left_w')
    let right_w=document.querySelector('.right_w')
    let fansRightC=document.querySelector('.fansRightC')
    console.log(data);
    if(data.data.key=='请先登录'){
        fansList(i,5)
    }else{
        console.log(data.data.key.data.total==null);
        if(data.data.key.data.total==null){
            console.log(data);
            fansRightC.innerHTML+=`
                <div class="fanEmpet">${data.data.key.data}</div>
            `
            fansList(i,5)
        }else{
            pages(Math.ceil(data.data.key.data.total/5),i)
            fansList(i,5)
        }
        left_w.onclick=()=>{
            i--
            if(i<0)i=0
            pages(Math.ceil(data.data.key.data.total/5),i)
            fansList(i,5)
        }
        right_w.onclick=()=>{
            i++
            if(i>data.data.key.data.total)i=data.data.key.data.total
            pages(Math.ceil(data.data.key.data.total/5),i)
            fansList(i,5)
        }
    }
})

function fansList(num,size){
    let fansRightC=document.querySelector('.fansRightC')
    fansRightC.innerHTML=``
    fanList(num,size).then(data=>{
        console.log(data);
        if(data.data.key!="请先登录"){
            let message=data.data.key
            console.log(message);
            if(message.data.list!=undefined){
                for(let i=0,len=message.data.list.length;i<len;i++){
                    let messagei=message.data.list[i]
                    fansRightC.innerHTML+=`
                    <div class="fansVessels">
                        <div class="header_f">
                            <div class="header_fs"></div>
                        </div>
                        <div class="fanMessage" onclick="window.location.href=''">${messagei.name}</div>
                        <div class="fanChat">
                            <div class="fanChats">私信</div>
                        </div>
                        <!--<div class="fanAttantion">
                            <div class="fanAttantions">
                                互相关注
                            </div>
                        </div>-->
                    </div>
                    `
                }
            }else{
                fansRightC.innerHTML+=`
                <div class="fanEmpet">${message.data}</div>
            `
            }
        }else{
            fansRightC.innerHTML+=`
                <div class="fanEmpet">请先登录</div>
            `
        }
    })
}